Fix Identity's ctrl_adder#1781
Merged
mhucka merged 4 commits intoquantumlib:mainfrom Jan 9, 2026
Merged
Conversation
Contributor
Author
mpharrigan
approved these changes
Jan 6, 2026
Collaborator
mpharrigan
left a comment
There was a problem hiding this comment.
nice, I agree this is probably the right fix
Collaborator
|
can you run to format the code. There's also a mypy type checking problem in the unit test. Since this is a unit test, you can add a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Identityis a special bloq: its controlled version is still an identity, but with a larger register, ie. callingIdentity(n).controlled(CtrlSpec(QAny(m)))gets usIdentity(n+m)The old version of
ctrl_adder()was usingAutopartitionwhich failed during decomposition asAutopartitionis not designed to merge registers and pass them to the inner bloq.This is fixed by this PR by replacing
AutopartitionwithPartition(s).This fix is functional but the resulting
show_bloq()output is less clean as the Partition steps are visible. An alternative (maybe better) fix is to keep usingAutopartitionbut mark the control registers asUnused(), but It is weird conceptually to not use Identity(n+m) as the controlled Identity.This PR also adds a test covering this bug.